import { getCategoryList } from '@/api/CategoryList'
import { getBannerList, reqGetFloorList } from '@/api/banner'
const state = {
    CategoryList: [],
    bannerList: [],
    floorList: []
}
const mutations = {
    // 获取三级菜单栏
    _getCategoryList(state, data) {
        state.CategoryList = data
    },
    // 获取轮播图数据
    _getBannerList(state, bannerList) {
        state.bannerList = bannerList
    },
    // 获取产品展示数据
    GETFLOORLIST(state, floorList) {
        state.floorList = floorList
    }
}
const actions = {
    // 三级菜单数据
    async getBaseCategoryList({ commit }) {
        let data = await getCategoryList()
        if (data.code === 200) {
            data.data.splice(-2, 2)
            commit('_getCategoryList', data.data)
        }
    },
    // mockJS轮播图数据
    async getBannerList({ commit }) {
        let data = await getBannerList()
        if (data.status === 200) {
            commit('_getBannerList', data.data)
        }
    },
    // 获取 floor 产品展示数据
    async getFloorList({ commit }) {
        let data = await reqGetFloorList()
        if (data.status === 200) {
            commit('GETFLOORLIST', data.data)
        }
        // console.log(data)
    }
}
const getters = {}

export default {
    state,
    mutations,
    actions,
    getters
}